﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RPGXEngine
{
    public class Command_Return : ICommand
    {
        #region ICommand Members

        public bool IsReturn { get { return true; } }
        public bool IsIf { get { return false; } }

        public List<ICommand> ChildrenCommands
        {
            get
            {
                return this._childCommands;
            }
        }
        private List<ICommand> _childCommands = new List<ICommand>();

        public IVariableType Execute(ScriptManager sm, FunctionScope scope)
        {
            IVariableType vt = null;

            if (this.ChildrenCommands.Count() > 0 &&
                this.ChildrenCommands[0] != null)
            {
                vt = this.ChildrenCommands[0].Execute(sm, scope);
            }
            else
            {
                vt = new VoidVariableType(String.Empty);
            }

            return vt;
        }

        #endregion
    }
}
